<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1. 实例化 Promise ，并封装异步任务
        let a =new Promise((resolve,reject)=>{
            setTimeout(()=>{
                if(Math.random()*200 >=100){
                    resolve('找到了')
                }else{
                    reject('加油')
                }
            },1000)
        })
         // 2. 获取异步任务的结果
         a.then(str =>{
            console.log(str);
         }).catch(res=>{
            console.log(res);
         })
    </script>
</body>
</html>